package com.itlong.cloud.app.dao;

import com.itlong.cloud.POJO.DTO.property.IotCloudElevatorStateDTO;
import com.itlong.cloud.POJO.PO.CloudElevatorOperateRecordPO;
import com.itlong.cloud.POJO.PO.ColdDataCloudElevatorOperateRecordPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      预约电梯用户行程数据访问接口
 * </desc>
 *
 * @createDate 2018/04/13
 */
@Repository
public interface IAppCloudElevatorCallStatusDao {

    /**
     * <desc>
     *      根据真实楼层查询楼层标识
     * </desc>
     *
     * @param dto
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/13
     */
    String findNaturalFloorByTruthFloor(IotCloudElevatorStateDTO dto);

    /**
     * <desc>
     *      根据楼层名称查询楼层标识
     * </desc>
     *
     * @param dto
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/13
     */
    String findNaturalFloorByLogicFloor(IotCloudElevatorStateDTO dto);

    /**
     * <desc>
     *      更新是否已到出发楼层状态
     * </desc>
     *
     * @param dto
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/13
     */
    Integer updateFromStatus(IotCloudElevatorStateDTO dto);

    /**
     * <desc>
     *      更新预约状态为预约完成
     * </desc>
     *
     * @param dto
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/13
     */
    Integer updateOperateStatus(IotCloudElevatorStateDTO dto);

    /**
     * <desc>
     *      检查该用户电梯预约状态是否是已完成
     * </desc>
     *
     * @param userId    用户id
     * @param deviceUnique 设备序列号
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/13
     */
    Integer checkSuccessState(@Param("userId") String userId,@Param("deviceUnique") String deviceUnique);

    /**
     * <desc>
     *      检查该用户电梯预约状态
     * </desc>
     *
     * @param userId    用户id
     * @param deviceUnique 设备序列号
     * @return
     * @author Qiang.S
     * @createDate 2020/04/17
     */
    Integer checkRecordState(@Param("userId") String userId,@Param("deviceUnique") String deviceUnique);

    /**
     * <desc>
     *      查询当前是否有预约中电梯状态
     * </desc>
     *
     * @param userId    用户id
     * @param deviceUnique 设备唯一码
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/13
     */
    Integer checkHaveCall(@Param("userId") String userId,@Param("deviceUnique") String deviceUnique);

    /**
     * <desc>
     *      删除一天前的电梯状态
     * </desc>
     *
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/13
     */
    public Integer deleteYestodayCallStatus();

    /**
     * <desc>
     *      将所有超过10分钟都没有预约完成的电梯状态修改为呼梯失败
     * </desc>
     *
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/13
     */
    public Integer setCallStatusAsCallDefeat();

    /**
     * <desc>
     *      将APP阅读状态更改为已读
     * </desc>
     *
     * @return
     * @author Jiaqi.X
     * @createDate 2018/04/17
     */
    public Integer updateAppRead(@Param("id") Integer id);

    /**
     * <desc>
     *      获取呼梯信息
     * </desc>
     *
     * @param userId
     * @param deviceUnique
     * @return
     * @author Jiaqi.X
     * @createDate 2019/09/05
     */
    Map<String,Object> getCallInfo(@Param("userId") String userId,@Param("deviceUnique") String deviceUnique);

    /**
     * <desc>
     *      获取用户信息
     * </desc>
     *
     * @return
     * @author Jiaqi.X
     * @createDate 2020/04/13
     */
    List<CloudElevatorOperateRecordPO> getUsers();

    /**
     * <desc>
     *      获取冷表数据
     * </desc>
     *
     * @param userId
     * @param deviceUnique
     * @return
     * @
     */
    List<ColdDataCloudElevatorOperateRecordPO> getColds(@Param("userId") String userId,@Param("deviceUnique") String deviceUnique,
                                                        @Param("pageSize") Integer pageSize);

    /**
     * <desc>
     *      批量保存
     * </desc>
     *
     * @param params
     * @author Jiaqi.X
     * @createDate 2020/04/13
     */
    void batchSaveColds(List<Map<String,Object>> params);

    /**
     * <desc>
     *      删除原数据
     * </desc>
     *
     * @param recordIds
     * @author Jiaqi.X
     * @createDate 2020/04/13
     */
    Integer deleteColds(@Param("recordIds") List<String> recordIds);

    /**
     * <desc>
     *      保存人员
     * </desc>
     *
     * @param params 数据参数
     * @return
     * @author Jiaqi.X
     * @createDate 2017/09/27
     */
    Integer save(Map<String,Object> params);
}
